home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / python-support / python2.6 / rdflib_tools / EARLPlugin.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  2.9 KB  |  63 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. ''' A Nose Plugin for EARL.
  5.  
  6. See Also: 
  7.   http://nose.python-hosting.com/
  8.   http://www.w3.org/TR/EARL10-Schema/ 
  9.  
  10. '''
  11. import logging
  12. import sys
  13. from nose.plugins import Plugin
  14. from nose.suite import TestModule
  15. from rdflib import URIRef, BNode, Literal
  16. from rdflib import RDF, RDFS
  17. from rdflib.Graph import Graph
  18. from rdflib.Namespace import NamespaceDict as Namespace
  19. from rdflib.util import date_time
  20. log = logging.getLogger(__name__)
  21. EARL = Namespace('http://www.w3.org/ns/earl#')
  22.  
  23. class EARLPlugin(Plugin):
  24.     '''
  25.     Activate the EARL plugin to generate a report of the test results
  26.     using EARL.
  27.     '''
  28.     name = 'EARL'
  29.     
  30.     def begin(self):
  31.         self.graph = Graph()
  32.         self.graph.bind('earl', EARL.uri)
  33.  
  34.     
  35.     def finalize(self, result):
  36.         self.graph.serialize('file:results-%s.rdf' % date_time(), format = 'pretty-xml')
  37.  
  38.     
  39.     def addDeprecated(self, test):
  40.         print 'Deprecated: %s' % test
  41.  
  42.     
  43.     def addError(self, test, err, capt):
  44.         print 'Error: %s' % test
  45.  
  46.     
  47.     def addFailure(self, test, err, capt, tb_info):
  48.         print 'Failure: %s' % test
  49.  
  50.     
  51.     def addSkip(self, test):
  52.         print 'Skip: %s' % test
  53.  
  54.     
  55.     def addSuccess(self, test, capt):
  56.         result = BNode()
  57.         self.graph.add((result, RDFS.label, Literal(test)))
  58.         self.graph.add((result, RDFS.comment, Literal(type(test))))
  59.         self.graph.add((result, RDF.type, EARL.TestResult))
  60.         self.graph.add((result, EARL.outcome, EARL['pass']))
  61.  
  62.  
  63.